﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
    xmlns:Controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" 
    xmlns:Animation="clr-namespace:Telerik.Windows.Controls.Animation;assembly=Telerik.Windows.Controls">

    <!-- Example layer colors -->
    <LinearGradientBrush x:Key="HeaderBackground" EndPoint="0 1">
        <GradientStop Offset="0" Color="#868686" />
        <GradientStop Offset="1" Color="#0D0D0D" />
    </LinearGradientBrush>

    <SolidColorBrush x:Key="TitleForeground" Color="#D3D3D3" />
    <SolidColorBrush x:Key="SubTitleForeground" Color="#5ABAB6" />

    <SolidColorBrush x:Key="ApplicationBackground" Color="#FFE5E5E5" />
    <SolidColorBrush x:Key="ApplicationBorderBrush" Color="#FFB5B5B5" />

    <!-- Menu colors -->
    <LinearGradientBrush x:Key="MenuBackground" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#FF666666" Offset="0"/>
        <GradientStop Color="#FF919191" Offset="1"/>
    </LinearGradientBrush>

    <!-- TopLevel MenuItem colors -->
    <SolidColorBrush x:Key="MenuDropDownBorder" Color="#8854BBE8" />
    <SolidColorBrush x:Key="MenuDropDownFrame" Color="#66333333" />
    <SolidColorBrush x:Key="MenuDorpDownInnerBorder" Color="White" />
    <SolidColorBrush x:Key="MenuDropDownBackground" Color="#FFF7F7F7" />


    <LinearGradientBrush x:Key="MenuItemTopLevelBackground_MouseOver" EndPoint="0 1">
        <GradientStop Color="#FF7dccee" Offset="0" />
        <GradientStop Color="#FF799fd9" Offset="0.06" />
        <GradientStop Color="#FF8ebdea" Offset="0.48" />
        <GradientStop Color="#FF348bda" Offset="0.49" />
        <GradientStop Color="#FF54bce9" Offset="0.83" />
        <GradientStop Color="#FF54bce9" Offset="0.98" />
    </LinearGradientBrush>

    <!-- TopLevel section -->
    <SolidColorBrush x:Key="MenuItemSeparatorDark" Color="#FFE4E4E4" />
    <SolidColorBrush x:Key="MenuItemSeparatorLight" Color="White" />

    <!-- Title -->
    <SolidColorBrush x:Key="MenuItemTitleForeground" Color="#FF0099CC" />

    <!-- Paragraph -->
    <SolidColorBrush x:Key="MenuItemParagraphForeground" Color="#FF595959" />

    <!-- Special Link -->
    <SolidColorBrush x:Key="MenuItemSpecialLinkForeground" Color="#FF0066CC" />

    <!-- Link MenuItem colors -->
    <!-- !! Foreground coloring is hardcoded in the storyboards -->

    <ControlTemplate x:Key="MenuItemParagraphControlTemplate" TargetType="Controls:RadMenuItem">
        <TextBlock x:Name="TextElement" Text="{Binding Content}" Foreground="{StaticResource MenuItemParagraphForeground}" TextWrapping="Wrap" FontSize="11" />
    </ControlTemplate>

    <ControlTemplate x:Key="MenuItemTitleControlTemplate" TargetType="Controls:RadMenuItem">
        <TextBlock x:Name="TextElement" Text="{Binding Content}" Foreground="{StaticResource MenuItemTitleForeground}" FontSize="16" />
    </ControlTemplate>

    <ControlTemplate x:Key="MenuItemLinkControlTemplate" TargetType="Controls:RadMenuItem">
        <TextBlock x:Name="TextElement" Text="{TemplateBinding Header}" TextDecorations="None" Foreground="#FF2C2C2C" FontSize="12">
				<VisualStateManager.VisualStateGroups>
					<VisualStateGroup x:Name="CommonStates">
						<VisualState x:Name="Unfocused"/>
						<VisualState x:Name="Focused">
							<Storyboard>
								<ColorAnimationUsingKeyFrames Storyboard.TargetName="TextElement" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)">
									<LinearColorKeyFrame KeyTime="00:00:00" Value="#FF0066CC" />
								</ColorAnimationUsingKeyFrames>
								<ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextElement" Storyboard.TargetProperty="TextDecorations">
									<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="Underline" />
								</ObjectAnimationUsingKeyFrames>
							</Storyboard>
						</VisualState>
					</VisualStateGroup>
				</VisualStateManager.VisualStateGroups>
        </TextBlock>
    </ControlTemplate>
    
    <ControlTemplate x:Key="MenuItemSpecialLinkControlTemplate" TargetType="Controls:RadMenuItem">
        <TextBlock x:Name="TextElement" TextDecorations="None" Foreground="{StaticResource MenuItemSpecialLinkForeground}" FontSize="11">
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="CommonStates">
                        <VisualState x:Name="Unfocused"/>
                        <VisualState x:Name="Focused">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextElement" Storyboard.TargetProperty="TextDecorations">
                                    <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="Underline" />
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <Run Text="» " />
                <Run Text="{Binding Content}" />
        </TextBlock>
    </ControlTemplate>

    <ControlTemplate x:Key="MenuItemTopLevelControlTemplate" TargetType="Controls:RadMenuItem">
        <Grid>
            <Rectangle x:Name="BackgroundVisual" Fill="{StaticResource MenuItemTopLevelBackground_MouseOver}" Opacity="0" />
            <TextBlock x:Name="TextElement" Text="{Binding Path=Account.FullName, Mode=OneWay, FallbackValue=Guest}" TextDecorations="None" Foreground="White" FontWeight="Bold" Margin="20 6 40 6" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="14" />
            <Path x:Name="DropDownArrow" Fill="White" Data="M0,0 L2,0 1,1" Stretch="Uniform" Width="7" Height="5" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="8 0 20 0" />
            <Popup x:Name="PART_Popup" HorizontalOffset="-1" VerticalOffset="-1">
                <Border x:Name="PopupContent" Margin="0 1 0 0" BorderBrush="{StaticResource MenuDropDownBorder}" BorderThickness="1" Background="{StaticResource MenuDropDownFrame}" Padding="6">
                    <Border Background="{StaticResource MenuDropDownBackground}" BorderBrush="{StaticResource MenuDorpDownInnerBorder}" BorderThickness="1">
                        <ItemsPresenter Margin="8 4" />
                    </Border>
                </Border>
            </Popup>

            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="CommonStates">
                    <VisualStateGroup.Transitions>
                        <VisualTransition GeneratedDuration="0:0:0.2"/>
                    </VisualStateGroup.Transitions>
                    <VisualState x:Name="Unfocused" />
                    <VisualState x:Name="Focused">
                        <Storyboard>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BackgroundVisual" Storyboard.TargetProperty="Opacity">
                                <LinearDoubleKeyFrame KeyTime="00:00:00.1" Value="1" />
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>

        </Grid>
    </ControlTemplate>

    <ControlTemplate x:Key="MenuItemTopLevelSectionControlTemplate" TargetType="Controls:RadMenuItem">
        <Grid>
            <ItemsPresenter />
            <Popup x:Name="PART_Popup" HorizontalOffset="-1" VerticalOffset="-1">
                <Rectangle />
            </Popup>
        </Grid>
    </ControlTemplate>

    <ControlTemplate x:Key="MenuItemTopLevelSectionSeparatorControlTemplate" TargetType="Controls:RadMenuItem">
        <Border BorderThickness="1 0 0 0" Background="{StaticResource MenuItemSeparatorLight}" BorderBrush="{StaticResource MenuItemSeparatorDark}" Width="2" Margin="4 32 8 8" />
    </ControlTemplate>

    <ControlTemplate x:Key="MenuItemGalleryControlTemplate" TargetType="Controls:RadMenuItem">
        <Grid>
            <ItemsPresenter />
            <Popup x:Name="PART_Popup">
                <Rectangle />
            </Popup>
        </Grid>
    </ControlTemplate>
    
    <ControlTemplate x:Key="MenuItemImageControlTemplate" TargetType="Controls:RadMenuItem">
        <Image Source="{Binding Content}" Cursor="Hand" Stretch="None" HorizontalAlignment="Left" />
    </ControlTemplate>

    <ControlTemplate x:Key="ParagraphImageMenuItemControlTemplate" TargetType="Controls:RadMenuItem">
        <Grid Cursor="Hand">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Image Grid.RowSpan="2" Grid.Column="0" Margin="4" HorizontalAlignment="Left" VerticalAlignment="Top" Stretch="None" Source="{Binding Image}"  />
            <TextBlock x:Name="TitleElement" Grid.Row="0" Grid.Column="1" Margin="4 4 4 -5" MaxWidth="200" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="13" Text="{Binding Title}" Foreground="Black" />
            <TextBlock x:Name="SummaryElement" Grid.Row="1" Grid.Column="1" Margin="4 -5 4 4" MaxWidth="200" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Summary}" FontSize="11" Foreground="{StaticResource MenuItemParagraphForeground}" />

            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="CommonStates">
                    <VisualState x:Name="Unfocused"/>
                    <VisualState x:Name="Focused">
                        <Storyboard>
                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="TitleElement" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)">
                                <LinearColorKeyFrame KeyTime="00:00:00" Value="#FF0066CC" />
                            </ColorAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="TitleElement" Storyboard.TargetProperty="TextDecorations">
                                <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="Underline" />
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>

        </Grid>
    </ControlTemplate>

    <Style x:Key="MenuStyle" TargetType="Controls:RadMenu">
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="VerticalAlignment" Value="Top" />
        <Setter Property="Background" Value="{StaticResource MenuBackground}"/>
        <Setter Property="BorderBrush" Value="Black"/>
        <Setter Property="BorderThickness" Value="1" />
    </Style>

    <Style x:Key="MenuItemTopLevelStyle" TargetType="Controls:RadMenuItem">
        <Setter Property="Template" Value="{StaticResource MenuItemTopLevelControlTemplate}"/>
        <Setter Property="SeparatorTemplateKey" Value="{StaticResource MenuItemTopLevelControlTemplate}"/>
        <Setter Property="SubmenuItemTemplateKey" Value="{StaticResource MenuItemTopLevelControlTemplate}"/>
        <Setter Property="TopLevelHeaderTemplateKey" Value="{StaticResource MenuItemTopLevelControlTemplate}"/>
        <Setter Property="TopLevelItemTemplateKey" Value="{StaticResource MenuItemTopLevelControlTemplate}"/>
        <Setter Property="SubmenuHeaderTemplateKey" Value="{StaticResource MenuItemTopLevelControlTemplate}"/>

        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Vertical" />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>

        <Setter Property="Animation:AnimationManager.AnimationSelector">
            <Setter.Value>
                <Animation:AnimationSelector>
                    <Animation:SlideAnimation Direction="In" SlideMode="Top" AnimationName="Expand" TargetElementName="PopupContent" />
                </Animation:AnimationSelector>
            </Setter.Value>
        </Setter>

    </Style>
    
    <Style x:Key="MenuItemTopLevelSectionStyle" TargetType="Controls:RadMenuItem">
        <Setter Property="Template" Value="{StaticResource MenuItemTopLevelSectionControlTemplate}"/>
        <Setter Property="SeparatorTemplateKey" Value="{StaticResource MenuItemTopLevelSectionSeparatorControlTemplate}"/>
        <Setter Property="SubmenuItemTemplateKey" Value="{StaticResource MenuItemTopLevelSectionControlTemplate}"/>
        <Setter Property="TopLevelHeaderTemplateKey" Value="{StaticResource MenuItemTopLevelSectionControlTemplate}"/>
        <Setter Property="TopLevelItemTemplateKey" Value="{StaticResource MenuItemTopLevelSectionControlTemplate}"/>
        <Setter Property="SubmenuHeaderTemplateKey" Value="{StaticResource MenuItemTopLevelSectionControlTemplate}"/>

        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Vertical" />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style x:Key="MenuItemGalleryStyle" TargetType="Controls:RadMenuItem">
        <Setter Property="Template" Value="{StaticResource MenuItemGalleryControlTemplate}"/>
        <Setter Property="SeparatorTemplateKey" Value="{StaticResource MenuItemGalleryControlTemplate}"/>
        <Setter Property="SubmenuItemTemplateKey" Value="{StaticResource MenuItemGalleryControlTemplate}"/>
        <Setter Property="TopLevelHeaderTemplateKey" Value="{StaticResource MenuItemGalleryControlTemplate}"/>
        <Setter Property="TopLevelItemTemplateKey" Value="{StaticResource MenuItemGalleryControlTemplate}"/>
        <Setter Property="SubmenuHeaderTemplateKey" Value="{StaticResource MenuItemGalleryControlTemplate}"/>
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style x:Key="MenuItemImageStyle" TargetType="Controls:RadMenuItem">
        <Setter Property="Template" Value="{StaticResource MenuItemImageControlTemplate}"/>
        <Setter Property="SeparatorTemplateKey" Value="{StaticResource MenuItemImageControlTemplate}"/>
        <Setter Property="SubmenuItemTemplateKey" Value="{StaticResource MenuItemImageControlTemplate}"/>
        <Setter Property="TopLevelHeaderTemplateKey" Value="{StaticResource MenuItemImageControlTemplate}"/>
        <Setter Property="TopLevelItemTemplateKey" Value="{StaticResource MenuItemImageControlTemplate}"/>
        <Setter Property="SubmenuHeaderTemplateKey" Value="{StaticResource MenuItemImageControlTemplate}"/>
        <Setter Property="Margin" Value="4 4 12 4" />
    </Style>
    
    <Style x:Key="MenuItemParagraphStyle" TargetType="Controls:RadMenuItem">
        <Setter Property="Template" Value="{StaticResource MenuItemParagraphControlTemplate}"/>
        <Setter Property="SeparatorTemplateKey" Value="{StaticResource MenuItemParagraphControlTemplate}"/>
        <Setter Property="SubmenuItemTemplateKey" Value="{StaticResource MenuItemParagraphControlTemplate}"/>
        <Setter Property="TopLevelHeaderTemplateKey" Value="{StaticResource MenuItemParagraphControlTemplate}"/>
        <Setter Property="TopLevelItemTemplateKey" Value="{StaticResource MenuItemParagraphControlTemplate}"/>
        <Setter Property="SubmenuHeaderTemplateKey" Value="{StaticResource MenuItemParagraphControlTemplate}"/>
        <Setter Property="Margin" Value="4" />
        <Setter Property="MaxWidth" Value="300" />
        <Setter Property="HorizontalAlignment" Value="Left" />
    </Style>
    
    <Style x:Key="MenuItemTitleStyle" TargetType="Controls:RadMenuItem">
        <Setter Property="Template" Value="{StaticResource MenuItemTitleControlTemplate}"/>
        <Setter Property="SeparatorTemplateKey" Value="{StaticResource MenuItemTitleControlTemplate}"/>
        <Setter Property="SubmenuItemTemplateKey" Value="{StaticResource MenuItemTitleControlTemplate}"/>
        <Setter Property="TopLevelHeaderTemplateKey" Value="{StaticResource MenuItemTitleControlTemplate}"/>
        <Setter Property="TopLevelItemTemplateKey" Value="{StaticResource MenuItemTitleControlTemplate}"/>
        <Setter Property="SubmenuHeaderTemplateKey" Value="{StaticResource MenuItemTitleControlTemplate}"/>
        <Setter Property="Margin" Value="4 3 4 1" />
        <Setter Property="MinWidth" Value="150" />
    </Style>
    
    <Style x:Key="MenuItemLinkStyle" TargetType="Controls:RadMenuItem">
        <Setter Property="Template" Value="{StaticResource MenuItemLinkControlTemplate}" />
        <Setter Property="SeparatorTemplateKey" Value="{StaticResource MenuItemLinkControlTemplate}" />
        <Setter Property="SubmenuItemTemplateKey" Value="{StaticResource MenuItemLinkControlTemplate}" />
        <Setter Property="TopLevelHeaderTemplateKey" Value="{StaticResource MenuItemLinkControlTemplate}" />
        <Setter Property="TopLevelItemTemplateKey" Value="{StaticResource MenuItemLinkControlTemplate}" />
        <Setter Property="SubmenuHeaderTemplateKey" Value="{StaticResource MenuItemLinkControlTemplate}" />
        <Setter Property="Margin" Value="4 3 4 2" />
    </Style>
    
    <Style x:Key="MenuItemSpecialLinkStyle" TargetType="Controls:RadMenuItem">
        <Setter Property="Template" Value="{StaticResource MenuItemSpecialLinkControlTemplate}" />
        <Setter Property="SeparatorTemplateKey" Value="{StaticResource MenuItemSpecialLinkControlTemplate}" />
        <Setter Property="SubmenuItemTemplateKey" Value="{StaticResource MenuItemSpecialLinkControlTemplate}" />
        <Setter Property="TopLevelHeaderTemplateKey" Value="{StaticResource MenuItemSpecialLinkControlTemplate}" />
        <Setter Property="TopLevelItemTemplateKey" Value="{StaticResource MenuItemSpecialLinkControlTemplate}" />
        <Setter Property="SubmenuHeaderTemplateKey" Value="{StaticResource MenuItemSpecialLinkControlTemplate}" />
        <Setter Property="Margin" Value="4 2 4 6" />
    </Style>
    <Style x:Key="ParagraphImageMenuItemStyle" TargetType="Controls:RadMenuItem">
        <Setter Property="Template" Value="{StaticResource ParagraphImageMenuItemControlTemplate}" />
        <Setter Property="SeparatorTemplateKey" Value="{StaticResource ParagraphImageMenuItemControlTemplate}" />
        <Setter Property="SubmenuItemTemplateKey" Value="{StaticResource ParagraphImageMenuItemControlTemplate}" />
        <Setter Property="TopLevelHeaderTemplateKey" Value="{StaticResource ParagraphImageMenuItemControlTemplate}" />
        <Setter Property="TopLevelItemTemplateKey" Value="{StaticResource ParagraphImageMenuItemControlTemplate}" />
        <Setter Property="SubmenuHeaderTemplateKey" Value="{StaticResource ParagraphImageMenuItemControlTemplate}" />
        <Setter Property="Margin" Value="0 0 0 4" />
    </Style>
    
    <telerik:HierarchicalDataTemplate x:Key="MenuItemTemplate" ItemsSource="{Binding}">
        <telerik:ContainerBinding.ContainerBindings>
            <telerik:ContainerBindingCollection>
                <telerik:ContainerBinding PropertyName="Header" Binding="{Binding Content}" />
                <telerik:ContainerBinding PropertyName="IsSeparator" Binding="{Binding IsSeparator}" />
                <!--
                    <telerik:ContainerBinding PropertyName="IsChecked" Binding="{Binding IsChecked}" />
                    <telerik:ContainerBinding PropertyName="IsEnabled" Binding="{Binding IsEnabled}" />
                    <telerik:ContainerBinding PropertyName="StaysOpenOnClick" Binding="{Binding StaysOpenOnClick}" />
                    <telerik:ContainerBinding PropertyName="Icon" Binding="{Binding Image}" />
                    -->
            </telerik:ContainerBindingCollection>
        </telerik:ContainerBinding.ContainerBindings>
        <TextBlock Text="{Binding Content}" />
    </telerik:HierarchicalDataTemplate>
</ResourceDictionary>
